package com.kaigejava.iterator.iterator;

import com.kaigejava.iterator.MenuItem;

import java.util.ArrayList;

/**
 * Created by kaigejava on 2019/9/7.
 * 实现了迭代器接口的中餐厅
 */
public class CakeHouseIterator  implements Iterator{
    private int position=0;
    private ArrayList<MenuItem> menuItems;
    public CakeHouseIterator(ArrayList<MenuItem> menuItems)
    {
        this.menuItems = menuItems;
        position=0;
    }
    @Override
    public boolean hasNext() {
        if(position<menuItems.size())
        {
            return true;
        }
        return false;
    }

    @Override
    public Object next() {
        MenuItem menuItem =menuItems.get(position);
        position++;
        return menuItem;
    }
}
